/*
 * Created by 岱青海蓝信息系统(北京)有限公司 on 17-3-3 上午11:29
 * Copyright (c) 2017. All rights reserved.
 */

package com.example.dqhl.recycleviewdemo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.dqhl.recycleviewdemo.R;
import com.example.dqhl.recycleviewdemo.modle.SqlModle;

import java.util.List;

/**
 * Created by dqhl on 17/3/3.
 */
public class SqlAdapter extends RecyclerView.Adapter<SqlAdapter.MyViewHolder> {

    private Context context;
    private List<SqlModle> sqlModleList;

    public SqlAdapter(Context context,List<SqlModle> sqlModleList){
        this.context = context;
        this.sqlModleList = sqlModleList;
    }
    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder myViewHolder = new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.linearout_sql, parent, false));
        return myViewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.tv_dateId.setText(sqlModleList.get(position).getId());
        holder.tv_dateName.setText(sqlModleList.get(position).getName());
        holder.tv_dateAge.setText(sqlModleList.get(position).getAge());
    }


    @Override
    public int getItemCount() {
        return sqlModleList.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tv_dateId;
        TextView tv_dateName;
        TextView tv_dateAge;


        public MyViewHolder(View view) {
            super(view);
            tv_dateId = (TextView) view.findViewById(R.id.tv_dateId);
            tv_dateName = (TextView) view.findViewById(R.id.tv_dateName);
            tv_dateAge = (TextView) view.findViewById(R.id.tv_dateAge);
        }
    }
}
